#include "stm32f1xx.h"
#include "gpio.h"
#include "keyscan.h"


int key1scan()
{
	int key1value = 0;
	if(HAL_GPIO_ReadPin(key1_GPIO_Port,key1_Pin) == 1)
		{
			HAL_Delay(20);
			if(HAL_GPIO_ReadPin(key1_GPIO_Port,key1_Pin) == 1)
				{
					key1value++;
				}
		}
	return(key1value);
}

int key2scan()
{
	int key2value = 0;
	float voltage = 0.00;
	if(HAL_GPIO_ReadPin(key2_GPIO_Port,key2_Pin) == 1)
		{
			HAL_Delay(20);
			if(HAL_GPIO_ReadPin(key2_GPIO_Port,key2_Pin) == 1)
			{
				key2value++;
				voltage += 0.05;
			}
		}
	return(key2value);
	return(voltage);
}

int switchscan()
{
	int switchvalue = 0;
	if(HAL_GPIO_ReadPin(switch_GPIO_Port,switch_Pin) == 1)
		{
			HAL_Delay(20);
			if(HAL_GPIO_ReadPin(switch_GPIO_Port,switch_Pin) == 1)
			{
				switchvalue++;
				switchvalue += 1;
			}
		}
	return(switchvalue);
}

int shortedscan()
{
	int shorted = 0;
	if(HAL_GPIO_ReadPin(shorted_GPIO_Port,shorted_Pin) == 0)
	{
		HAL_Delay(20);
		if(HAL_GPIO_ReadPin(shorted_GPIO_Port,shorted_Pin) == 0)
		{
			shorted = 1;
		}
	else
		{
			shorted = 0;
		}
	}
}